package com.moss.system.service.impl;

import com.moss.common.entity.SysCompanyEntity;
import com.moss.system.mapper.CompanyMapper;
import com.moss.system.service.CompanyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Resource
    CompanyMapper companyMapper;


    @Override
    public List<SysCompanyEntity> selectList(SysCompanyEntity company) {
        return companyMapper.selectList(company);
    }

    @Override
    public void saveCompany(SysCompanyEntity company) {
        companyMapper.insert(company);
    }

    @Override
    public SysCompanyEntity selectById(String companyId) {
        return companyMapper.selectById(companyId);
    }

    @Override
    public void updateCompany(SysCompanyEntity company) {
        companyMapper.updateById(company);
    }

    @Override
    public void deleteCompany(String[] companyId) {
        companyMapper.deleteById(companyId);
    }


    @Override
    public boolean checkCodeAndNameEq(String uniformCode, String companyName) {
        SysCompanyEntity company = companyMapper.selectByCode(uniformCode);
        return company != null && companyName.equals(company.getCompanyName());
    }
}
